<?php
/**
 * this class manages the admin tabs
 * 
 */
class DigNavigation_Service_Tab
{
    public static function listAll() {
        $tabs = array();
        foreach( Dig_Service_Module::listAll() as $module => $settings ) {
            if( isset($settings['navigation']['adminTabs'] )) {
                foreach ($settings['navigation']['adminTabs'] as $tab) {
                    $tabPosition = $tab['position'];
                    if(isset( $tabs[$tabPosition] )) {
                        throw new DigNavigation_Exception('Admin tab position ' .
                            $tabPosition . ' is already set. ' . $module .
                            ' attempted to reset tab');
                    }
                    $tabs[$tabPosition] = $tab;
                }
            }
        }
        if(count($tabs) > 0) {
            ksort($tabs);
            return $tabs;
        }
        return false;
    }

    public static function getDefault()
    {
        $tabs = self::listAll();
        return $tabs[0];
    }
}
?>
